package com.tanhua.admin.task;

import com.tanhua.admin.service.AnalysisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.SimpleFormatter;

//定义任务类
//类给容器管理
//编写定时执行的java方法，没有参数，没有返回值
@Component
public class Analysistask {
    @Autowired
    private AnalysisService analysisService;
    //每小时计算日志数据写入统计表
    //@Scheduled(cron = "0/5 * * * * ?")
    @Scheduled(cron = "0 0 0/1  * * ?")
    public void analisis(){
        String now = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
        System.out.println("当前时间"+now);
        try{
            analysisService.analisis();
        }catch (Exception e){
            e.printStackTrace();
        }

    }
}
